<!--
 Copyright 2017 ZTE Corporation.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->
<div class="container" style="margin-top: 20px">
    <form class="form-inline">
        <div class="form-body">
            <div class="row form-group col-xs-12">
                <div class="col-xs-4">
                    <label class="col-xs-3 control-label" style="padding-top: 8px">
                        {{"common_status"|translate}}
                    </label>
                    <select #selection class="form-control" style="width: 60%" id="status" (change)="switch(selection.value)" [(ngModel)]="activeText"
                        name="activestatus">
                      <option *ngFor="let a of activeStatus" [value]="a">{{a|translate}}</option>
                    </select>
                </div>

                <div class="col-xs-4">
                    <label for="userName" class="col-xs-3 control-label" style="padding-top: 8px">
                        <span>{{"common_keyword"|translate}}</span>
                    </label>
                    <input class="form-control ng-untouched ng-pristine ng-valid" style="width: 60%" placeholder='{{"field_rule_name_Add_Page"|translate}}'
                        type="text" [(ngModel)]="ruleModel.rulename" name="name">
                </div>

                <div class="fmrule_btn_group display_table">
                    <div class="inline">
                        <button id="batchDeleteButton" class="btn btn-primary" (click)="searchRules()">
                            <span class="glyphicon glyphicon-search" style="padding-top: 2px"></span>
                            <span>{{"common_query"|translate}}</span>
                        </button>
                        <button class="btn btn-secondary" (click)="reset()" style="margin-left: 10px">
                            <span class="glyphicon glyphicon-refresh"></span>
                            <span>{{"common_reset"|translate}}</span>
                        </button>
                    </div>
                </div>
            </div>

            <div class="row form-group col-xs-12" style="margin-top: 10px">
                <div class="">
                    <div class="inline">
                        <button type="button" routerLink='/ruleInfo' class="btn btn-info">
                    <span class="glyphicon glyphicon-plus"></span>
                    <span>{{"common_add"|translate}}</span>
                    </button>
                    </div>
                </div>
            </div>
        </div>

    </form>
    <div>
        <div class="row form-group col-xs-12" style="margin-top: 20px">{{"common_total1"|translate}}{{totalcount}}{{"common_total2"|translate}}</div>
        <table class="table table-bordered table-striped customtable table-hover">
            <thead class="nf_thead">
                <tr class="heading">
                    <td>{{"field_rule_name_Add_Page"|translate}}</td>
                    <td>{{"common_status"|translate}}</td>
                    <td>{{"field_create_time"|translate}}</td>
                    <td>{{"field_creator"|translate}}</td>
                    <td>{{"field_update_time"|translate}}</td>
                    <td>{{"common_operator"|translate}}</td>
                </tr>
            </thead>
            <tbody>
                <tr *ngFor="let rule of rules">
                    <td><a routerLink="/ruleInfo/{{rule.ruleid}}&add">{{rule.rulename}}</a></td>
                    <td [hidden]="rule.enabled === 1" style="text-align: center"><span value=1><img src="public/thirdparty/images/round_off.png" alt=""></span></td>
                    <td [hidden]="rule.enabled === 0" style="text-align: center"><span value=0><img src="public/thirdparty/images/round_on.png" alt=""></span></td>
                    <td>{{rule.createtime | date:'yyyy-MM-dd HH:mm:ss'}}</td>
                    <td>{{rule.creator}}</td>
                    <td>{{rule.updatetime | date:'yyyy-MM-dd HH:mm:ss'}}</td>
                    <td>
                        <span (click)="updateRule(rule); $event.stopPropagation()" style="cursor: pointer;margin: 0 5px">
                        <img src="public/thirdparty/images/edit.png" alt="">
                    </span>
                        <span>
                        
                    </span>
                        <span [hidden]="rule.enabled===0" class="" (click)="on_off(rule); $event.stopPropagation()" style="cursor: pointer;margin: 0 5px"> 
                        <img src="public/thirdparty/images/on.png" alt="">
                    </span>
                        <span [hidden]="rule.enabled===1" class="" (click)="on_off(rule); $event.stopPropagation()" style="cursor: pointer;margin: 0 5px">
                        <img src="public/thirdparty/images/off.png" alt="">
                    </span>

                        <span class="" id={{rule.ruleid}} (click)="delete(rule)" style="cursor: pointer;margin: 0 5px">
                         <img src="public/thirdparty/images/delete.png" alt="">
                    </span>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    <div id="deleteTimingTaskDlg" style="display: none;">
        <div id="deleteTimingTaskContent">
            <div class="deletePromptMessage">
                <span>{{"message_is_delete"|translate}}</span>
            </div>
            <div style="float:rightl;padding-top: 10px;margin-bottom: -20px" class="">
                <button class="btn btnDefault btnmrg" data-popmodal-but="ok">
                    <span>{{"common_confirm"|translate}}</span>
                </button>
                 <button class="btn btnDefault btnmrg" type="button" data-popmodal-but="cancel">
                    <span>{{"common_cancel"|translate}}</span>
                </button>
            </div>
        </div>
    </div>

    <div id="deleteActiveAlarmRuleDlg" style="display: none;">
        <div id="deleteActiveRuleContent">
            <div class="deletePromptMessage">
                <span>{{"warn_delete_info"|translate}}</span>
            </div>
            <div style="float:right;padding-top:10px">
                <button class="btn btnDefault btnmrg" data-popmodal-but="ok">
                    <span>{{"common_confirm"|translate}}</span>
                </button>
            </div>
        </div>
    </div>